package com.example.demo.controller.admin;

import com.example.demo.dao.Admin;
import com.example.demo.mapper.AdminMapper;
import com.example.demo.service.adminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@Controller
public class LoginController {
    @Autowired
    private adminService adminService;
    @RequestMapping("/login")
    public String showlogin(){
        return "admin-login";
    }


    //管理员登录
    @RequestMapping(value = "/adminlogin",method= RequestMethod.POST)
    public String login(HttpServletRequest request ,Model model){
          String pname=request.getParameter("adminname");
          String pwd=request.getParameter("password");
          String msg="";
        if(adminService.checkUser(pname,pwd)==null){
             msg = "账户密码错误";
            model.addAttribute("msg",msg);
            return "admin-login";
        }
        else{
            return "indent-list";
        }
    }
}
